package com.lsk.servicemap.remote;

import com.lsk.internalcommon.DTO.ResponseResult;
import com.lsk.internalcommon.constant.AMapConfigConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class DicDistrictClient {
    @Value("${map.key}")
    private String mapKey;

    @Autowired
    private RestTemplate restTemplate;
    public String dicdistrict(String keywords){
        //拼接url
        StringBuilder url = new StringBuilder();
        url.append(AMapConfigConstants.DISTRICT_URL);
        url.append("?"+"keywords=");
        url.append(keywords+"&subdistrict=3");
        url.append("&key="+mapKey);

        //解析结果
        ResponseEntity<String> entity = restTemplate.getForEntity(url.toString(), String.class);
        //插入到数据库
        return entity.getBody();
    }
}
